<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Wuye/noticeList')}">物业公告</a></li>
        <li class="active"><a href="{:url('Wuye/noticeAdd')}">添加公告</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Wuye/noticeSvae')}">

        <input type="hidden" name="id" value="{$list.id|default =''}">

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>公告类别:</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="cate_id">
                    <option value="0">请选择</option>
                    <empty name="$list">
                        <volist name="cate" id="cate">
                            <option value="{$cate.id}">{$cate.name}</option>
                        </volist>
                    <else />
                        <volist name="cate" id="cate">
                            <option value="{$cate.id}" <if condition='$list.cate_id eq $cate.id'>selected</if>>{$cate.name}</option>
                        </volist>
                    </empty>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>公告名称:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="title" value="{$list.title|default =''}">
            </div>
        </div>

        <volist name="cates" id="cates">
            <if condition="$cates.id eq 16">
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="form-required">*</span></label>
                    <div class="col-md-6 col-sm-10">
                        <label>
                            <input type="checkbox" name="is_show" value="" <if condition="isset($list.is_show) AND $list.is_show == 1">checked</if>>是否在首页显示<b style="color: red;">(只有物业公告才可以在首页显示)</b>
                        </label>
                    </div>
                </div>
            </if>
        </volist>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>公告简述:</label>
            <div class="col-md-6 col-sm-10">
                <textarea class="form-control" name="desc" style="overflow-x:hidden">{$list.desc|default =''}</textarea>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>公告内容:</label>
            <div class="col-md-6 col-sm-10">
                <td>
                    <textarea class="form-control" name="content" style="overflow-x:hidden;min-height: 150px;">{$list.content|default =''}</textarea>
            </div>
        </div>

        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:lang("SAVE")}</button>
        </div>
    </form>

</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?ids=" + selectedCategoriesId, '请选择分类', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>
</body>
</html>